package com.example.algorithm.no0003.solution;

import com.example.algorithm.no0003.Solution;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 解答-无重复字符的最长子串-For暴力解法
 * @ClassName MapSolution
 * @Author Administrator
 * @Date 2020/5/20 10:26
 * @Version 1.0.0
 */
public class ForSolution implements Solution {
    @Override
    public int lengthOfLongestSubstring(String s) {
        int maxLength = 0;
        for (int i = 0; i < s.length(); i++) {
            List<Character> characters = new ArrayList<>();
            for (int j = i; j < s.length(); j++) {
                if (characters.contains(s.charAt(j))) {
                    break;
                }
                characters.add(s.charAt(j));
                maxLength = Math.max(characters.size(), maxLength);
            }
        }
        return maxLength;
    }
}
